let sortWeightId = "frm-lose-weight";
let sortTyp = 1;
$(document).ready(function () {
    $('.merger-title').hide();
    $('[data-toggle="tooltip"]').tooltip();
    //报损显示弹窗
    $('#frm-lose-model').on('show.bs.modal', function (event) {
        var button = $(event.relatedTarget); // 触发事件的按钮
        var recipient = button.data('whatever'); // 解析出data-whatever内容
        if (recipient) {
            var modal = $(this);
            modal.find('.modal-title').text('Message To ' + recipient);
            modal.find('.modal-body input').val(recipient);
        }
    });

    //报损隐藏弹窗
    $('#frm-lose-model').on('hide.bs.modal', function (event) {
        $('#goods-detail-id').val("");
        $('#frm-lose-weight').val("");
        $('#frm-lose-select').selectpicker('val', ['noneSelectedText']);
    });

    //报损下拉
    // $('#frm-lose-select').selectpicker('render');
    $("#frm-lose-select").on("changed.bs.select", function (e) {
        let temp = $(this).val();
        $('#goods-detail-id').val(temp);
    });
});

function storageDoneCallBack(data, cancel, opt) {
    if (!cancel) {
        const obj = data.data;
        delResponseFromWcs(data, opt);
        if (obj.code == 0) {
        } else {
            $('#message-content').text(obj.msg);
            setTimeout("$('#message-content').text('')", 5000);
        }
    }
}

//回调处理
function weighRespCallBack(data, cancel, opt) {
    if (!data) {
        return;
    }
    console.log(">>>>>>>>>>称重回调");
    if (cancel) {
        //todo 隐藏操作按钮等之类的
        $("#empty-btn").hide();
    } else {
        const obj = data.data;
        delResponseFromWcs(data, opt);
        if (obj.code == 0) {
        } else {
            $('#merge-box-up').show();
            $('#message-content').text(obj.msg);
            setTimeout("$('#message-content').text('')", 5000);
        }

    }
}

//发送指令响应回调
function wcsToWmsResponseCallBack(data, cancel, opt) {
    if (!data) {
        return;
    }
    if (cancel) {
        //todo 隐藏操作按钮等之类的
        // dealWithError("emptyNumber",'');
    } else {
        delResponseFromWcs(data, opt);
        const obj = data.data;
        console.log("KKKKKK:" + JSON.stringify(obj));
        if (obj.code == 1) {
            const mergeBoxCode = $('#merge-box-code').text();
            if (!mergeBoxCode) {
                //是主箱则重新展示
                $('#' + obj.boxCode).hide();
            } else if (obj.boxCode == mergeBoxCode) {
                $('#' + obj.boxCode).hide();
            } else {
                //是拿空的货箱，重新展示空箱入库按钮
                $('#' + obj.boxCode).show();
            }
            $('#merge-box-up').show();
            if ((obj.totalWeight && obj.totalWeight > 0) || (obj.actWeight && obj.actWeight > 0)) {
                BootstrapDialog.alert(obj.msg + ",称重重量：" + obj.totalWeight + "；实际重量：" + obj.actWeight);
            } else {
                BootstrapDialog.alert(obj.msg);
            }

        } else {

        }
        setTimeout("$('#message-content').text('')", 7000);
    }
}

//分拣称重
function sortWeightCallBack(data, cancel, opt) {
    if (!data) {
        return;
    }
    console.log("分拣称重响应：" + JSON.stringify(data));
    if (!cancel) {
        delResponseFromWcs(data, opt);
        const obj = data.data;
        if (obj.code == 0) {
        } else {
            $('#merge-box-up').show();
            $('#message-content').text(obj.msg);
            setTimeout("$('#message-content').text('')", 5000);
        }
    }
}

//货箱离开库位
function leaveBufferPosCallBack(data, cancel, opt) {

    if (!data) {
        return;
    }
    console.log("入库离开缓存位响应：" + JSON.stringify(data));
    if (!cancel) {
        delResponseFromWcs(data, opt);
        const obj = data.data;
        if (obj.code === 0) {
            const mergeBoxCode = $('#merge-box-code').text();
            const opt = {boxCode: obj.boxCode, clientId: $('#client-id').val()};
            $('#ware-box-code').val("");
            $('#goods-box-code').val("");
            $('#merge-box-code').text("");
            $('#merge-box-list').bootstrapTable('removeAll');
            $('#merge-btn').show();
            $('#merge-box-up').hide();
        } else {
            BootstrapDialog.alert(obj.msg);
        }
    }
}

//出库到缓存位
function inBufferPosCallBack(data, cancel, opt) {
    if (!data) {
        merge(true, 0);
        return;
    }
    if (!cancel) {
        //todo 逻辑处理
        const obj = data.data;
        console.log("ooooooooooooo:" + JSON.stringify(obj));
        if (obj.code === 0) {
            selectFrmLossBox(false, obj.boxCode);
            $('#merge-box-code').text(obj.boxCode);
            selectBoxDetailByBoxCode(obj.boxCode);
            $('#merge-btn').show();
            $('#merge-box-up').show();
            $('#sort-box-up-force').show();
        } else {
            delResponseFromWcs(data, opt);
        }

    } else {
        //todo 按钮隐藏之类的
    }
}

/**
 * 货箱离开缓存位回调，暂时不需要
 * @param mergeBoxCode
 * @param opt
 */
function frmLossLeaveBuffer(mergeBoxCode, opt) {
    $.ajax({
        type: "POST",
        url: "/wcs/box/detail/frmLossLeaveBuffer",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(opt),
        dataType: "json",
        success: function (data) {
            if (data.code == 0) {
                $('#ware-box-code').val("");
                $('#goods-box-code').val("");
                $('#merge-box-code').text("");
                $('#merge-box-list').bootstrapTable('removeAll');
                $('#merge-btn').show();
                $('#merge-box-up').hide();
            } else {
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            BootstrapDialog.alert({
                title: "信息提示！",
                closable: false,
                message: XMLHttpRequest.responseJSON.msg
            });
        }
    });
}

//查询货箱详情
function selectBoxDetailByBoxCode(boxCode) {
    const opt = {};
    opt['boxCode'] = boxCode;
    $.ajax({
        type: "POST",
        url: "/wcs/box/detail/selectBoxDetailByBoxCode",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(opt),
        dataType: "json",
        async: false,//后面需校验货箱是否空箱而入库，异步会造成数据不准确
        success: function (data) {
            if (data.code == 0) {
                if (data.data) {
                    console.log("selectBoxDetailByBoxCode:" + JSON.stringify(data.data));
                    initOutBoxList(data.data);
                }
            } else {
                BootstrapDialog.alert(data.msg);
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            $('#check-weight').show();
            if (XMLHttpRequest.responseJSON) {
                if (XMLHttpRequest.responseJSON.msg) {
                    BootstrapDialog.alert(XMLHttpRequest.responseJSON.msg);
                } else {
                    BootstrapDialog.alert(XMLHttpRequest.responseJSON.message);
                }
            }
        }
    });
}

function merge(flag, boxCode) {
    if (flag) {
        BootstrapDialog.confirm({
            title: "信息提示",
            message: "是否要执行临期出库操作?",
            btnCancelLabel: '返回',
            btnOKLabel: '确认',
            callback: function (result) {
                // 点击确定按钮时，result为true
                if (result) {
                    const clientId = $('#client-id').val();
                    downloadBox(clientId);
                    selectFrmLossBox(flag, boxCode);
                } else {
                    parent.location.reload();
                }
            }
        });
    }
}

/**
 * 查询到达缓存位货箱商品
 * @param flag
 * @param boxCode
 */
function selectFrmLossBox(flag, boxCode) {
    $('.merger-title').show();
    const clientId = $('#client-id').val();
    const opt = {};
    const model = {};
    model['status'] = 1;
    model['type'] = 1;
    model['treated'] = false;
    model['dataType'] = "HSCK";
    model['bigProduct'] = 0;
    opt['data'] = model;
    $.ajax({
        type: "POST",
        url: "/wcs/record/untreated/list",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(opt),
        dataType: "json",
        async: false,
        success: function (data) {
            if (data.code == 0) {
                if (data.data) {
                    initMergeBoxDetailList(data.data);
                }
            } else {
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            BootstrapDialog.alert({
                title: "信息提示！",
                closable: false,
                message: XMLHttpRequest.responseJSON.msg
            });
        }
    });
}

/**
 * 下架货箱
 * @param clientId
 */
function downloadBox(clientId) {
    $.ajax({
        type: "POST",
        url: "/wcs/box/downloadFrmLossBox",
        contentType: "application/json;charset=UTF-8",
        data: clientId,
        dataType: "json",
        async: false,
        success: function (data) {
            console.log("data>" + JSON.stringify(data));
            if (data.code == 0) {

            } else {
                BootstrapDialog.alert(data.msg);
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            BootstrapDialog.alert({
                title: "信息提示！",
                closable: false,
                message: XMLHttpRequest.responseJSON.msg
            });
        }
    });
}

//需要放入货箱的物品列表
function initOutBoxList(goodsBoxList) {
    $('#merge-box-list').bootstrapTable('destroy');
    $('#merge-box-list').bootstrapTable({
        data: goodsBoxList,
        method: 'post',
        pagination: false,//不分页
        sortable: false, //不排序
        sidePagination: "server",
        uniqueId: 'id',
        striped: true,
        queryParams: function (params) {
            //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            let temp = $("#search-condition").serializeJSON();
            return temp;
        }, onLoadSuccess: function (data) {
            $("#merge-box-list").bootstrapTable("load", goodsBoxList);
        },
        columns: [{
            field: 'spuName',
            title: '商品'
        }, {
            field: 'supplierCode',
            title: '供应商'
        }, {
            field: 'quantity',
            title: '数量'
        }, {
            field: 'weight',
            title: '重量'
        }, {
            field: 'shelfLife',
            title: '保质期'
        }, {
            field: 'spuId',
            title: '原料',
            visible: false
        }, {
            field: 'opt',
            title: '操作',
            align: 'center',
            valign: 'middle',
            formatter: actionFormatter,
        }]
    });
}

function actionFormatterRemove(value, row, index, field) {
    let result = '';
    result += '<button type="button" id="' + row.id + '_entry" class="btn btn-primary" onclick="removeReturnEntry(\'' + row.id + '\')">移除</button>';
    return result;
}

function removeReturnEntry(id) {
    const std = $('#merge-box-list').bootstrapTable('getData');
    const boxCode = $("#merge-box-code").text();
    if (Array.isArray(std) || (boxCode && boxCode!=="")) {
        BootstrapDialog.alert("临期商品货箱存在或者临期商品货箱列表存在则不能处理");
        return;
    }
    removeFrmLoss(id, 'merge-table-list')
}

//操作栏的格式化
function actionFormatter(value, row, index, field) {
    let result = '';
    const frmLossList = $('#merge-table-list').bootstrapTable('getData');
    if (frmLossList && frmLossList.length > 0) {
        for (let i = 0; i < frmLossList.length; i++) {
            const frmLoss = frmLossList[i];
            console.log("frmLossList:" + JSON.stringify(frmLoss));
            console.log("row:" + JSON.stringify(row));
            if (frmLoss.spuId == row.spuId && frmLoss.skuCode == row.skuCode && frmLoss.productDate == row.produceDate) {
                result += '<button type="button" id="' + row.id + '_entry" class="btn btn-primary" onclick="removeFrmLoss(\'' + row.id + '\',\'merge-box-list\')">报损出库</button>';
                break;
            }
        }
    }
    return result;
}

//展示临期商品列表
function initMergeBoxDetailList(goodsBoxDetailList) {
    $('#merge-table-list').bootstrapTable('destroy');
    $('#merge-table-list').bootstrapTable({
        data: goodsBoxDetailList,
        method: 'post',
        pagination: false,//不分页
        sortable: false, //不排序
        sidePagination: "server",
        uniqueId: 'id',
        striped: true,
        queryParams: function (params) {
            //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            let temp = $("#search-condition").serializeJSON();
            return temp;
        },
        onLoadSuccess: function (data) {
            $("#merge-table-list").bootstrapTable("load", goodsBoxDetailList);
        },
        columns: [{
            field: 'spuName',
            title: '商品'
        }, {
            field: 'temperatureZone',
            title: '温区'
        }, {
            field: 'supplierCode',
            title: '供应商'
        }, {
            field: 'quantity',
            title: '数量'
        }, {
            field: 'weight',
            title: '重量'
        }, {
            field: 'shelfLife',
            title: '保质期'
        }, {
            field: 'spuId',
            title: '原料',
            visible: false
        }, {
            field: 'opt',
            title: '操作',
            align: 'center',
            valign: 'middle',
            formatter: actionFormatterRemove,
        }]
    });
}


//原料报损
function frmLose() {
    $('#frm-lose-select').html('');
    let html = '';
    const boxList = $('#merge-table-list').bootstrapTable('getData');
    if (boxList && boxList.length > 0) {
        let flag = false;
        for (let i = 0; i < boxList.length; i++) {
            const boxDetail = boxList[i];
            // if (boxDetail.spuName && boxDetail.id) {
            if (boxDetail.id) {
                if (!flag) {
                    $('#goods-detail-id').val(boxDetail.id);
                }
                flag = true;
                html += '<option value="' + boxDetail.id + '" class="opt-frm-inf" style="height: 30px;padding-top: 5px;">' + boxDetail.spuName + '&nbsp;&nbsp;/&nbsp;&nbsp;' + boxDetail.weight + '</option>';
            }
        }
    }
    $('#frm-lose-select').append(html);
    $('#frm-lose-select').selectpicker('refresh');
    $('#frm-lose-model').modal({
        keyboard: false
    })
    sortWeightInfo("merge-table-list", sortWeightId, sortTyp, 1, null, 0);
}

//原料报损：取消/报损->false/true
function frmLoseClick(cancel) {
    if (cancel) {
        const id = $('#goods-detail-id').val();
        if (!id) {
            BootstrapDialog.alert("请选择报损原料");
            return;
        }
        const frmLoseWeight = $('#frm-lose-weight').val();
        if (!checkPrice(frmLoseWeight)) {
            BootstrapDialog.alert("输入重量格式不符");
            return;
        }
        const orderRow = $('#merge-table-list').bootstrapTable('getRowByUniqueId', id);
        console.log("合箱原料：" + JSON.stringify(orderRow));
        if (orderRow) {
            if (frmLoseWeight > orderRow.weight) {
                BootstrapDialog.alert("报损重量大于货箱内原料重量");
                return;
            } else {
                console.log("货箱信息更改前：" + JSON.stringify(orderRow));
                $('#merge-table-list').bootstrapTable('removeByUniqueId', id);
                orderRow.weight = parseFloat(orderRow.weight - frmLoseWeight).toFixed(2);
                console.log("货箱信息更改后：" + JSON.stringify(orderRow));
                insertRow(orderRow, 'merge-table-list', true);
            }
        } else {
            BootstrapDialog.alert("报损原料信息不存在");
            return;
        }
        $('#from-lose-goods-detail-box-code').val($('#merge-box-code').text());
        const opt = $("#form-frm-lose").serializeJSON();
        opt['clientId'] = $('#client-id').val();
        opt['boxCode'] = $('#merge-box-code').text();
        opt['type'] = 1;
        $.ajax({
            type: "POST",
            url: "/wcs/box/detail/updateFrmLoseById",
            contentType: "application/json;charset=UTF-8",
            data: JSON.stringify(opt),
            dataType: "json",
            success: function (data) {
                if (data.code == 0) {
                    $('#frm-lose-model').modal('hide');
                } else {
                    BootstrapDialog.alert(data.msg);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                if (XMLHttpRequest.responseJSON) {
                    if (XMLHttpRequest.responseJSON.msg) {
                        BootstrapDialog.alert(XMLHttpRequest.responseJSON.msg);
                    } else {
                        BootstrapDialog.alert(XMLHttpRequest.responseJSON.message);
                    }
                }
            }
        });
    } else {
        console.log("2222222222222");
    }
}

//分拣称重socketIo响应
function electronicWeightCallBack(data) {
    console.log("称重数据返回：" + data);
    if (data) {
        const vc = JSON.parse(data);
        if (vc.weight) {
            sortWeightInfo("sort-spu-table", sortWeightId, sortTyp, 0, vc, 0);
        } else {
            console.log("分拣/报损称重异常：" + data);
        }
    }
}

//入库缓存位扫码响应
function pageEntryCallBack(data) {
    console.log("入库缓存位扫码响应：" + data);
    if (data) {
        const vc = JSON.parse(data);
        if (vc.code == 0) {
            const resultData = vc.data;
        }
    }
}

//强制入库
function entryForce() {
    const boxCode = $('#merge-box-code').text();
    if (!boxCode) {
        BootstrapDialog.alert("货箱编号为空");
        return;
    }
    $('#ware-box-code').val(boxCode);
    $('#goods-box-code').val(boxCode);
    BootstrapDialog.confirm({
        title: '信息提示',
        message: '是否强制入库?',
        btnCancelLabel: '取消', // <-- Default value is 'Cancel',
        btnOKLabel: '确定', // <-- Default value is 'OK',
        callback: function (result) {
            if (!result) {
                return;
            }
            //材料箱
            const ops = $("#form-param").serializeJSON();
            //原料箱剩余物料
            /*const entry = $('#sort-spu-table').bootstrapTable('getData');
            if (entry && entry.length > 0) {
                ops['list'] = entry;
            }*/
            $('#sort-box-up-force').hide();
            $.ajax({
                type: "POST",
                url: "/wcs/entryForce",
                contentType: "application/json;charset=UTF-8",
                data: JSON.stringify(ops),
                dataType: "json",
                success: function (data) {
                    console.log(data);
                    if (data.code == 0) {

                    } else {
                        $('#sort-box-up-force').show();
                        $('#merge-box-code').text($('#goods-box-code').val());
                        BootstrapDialog.alert(data.msg);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    if (XMLHttpRequest.responseJSON) {
                        if (XMLHttpRequest.responseJSON.msg) {
                            BootstrapDialog.alert(XMLHttpRequest.responseJSON.msg);
                        } else {
                            BootstrapDialog.alert(XMLHttpRequest.responseJSON.message);
                        }
                    }
                }
            });
        }
    });
}

//出库
function downloadMergeBox() {
    const clientId = $('#client-id').val();
    $.ajax({
        type: "POST",
        url: "/wcs/box/downloadMergeBox",
        contentType: "application/json;charset=UTF-8",
        data: clientId,
        dataType: "json",
        success: function (data) {
            if (data.code == 0) {

            } else {
                $('#merge-box-code').text($('#goods-box-code').val());
                BootstrapDialog.alert(data.msg);
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            if (XMLHttpRequest.responseJSON) {
                if (XMLHttpRequest.responseJSON.msg) {
                    BootstrapDialog.alert(XMLHttpRequest.responseJSON.msg);
                } else {
                    BootstrapDialog.alert(XMLHttpRequest.responseJSON.message);
                }
            }
        }
    });
}

//临期报损后入库
function mergeBoxUp() {
    const boxCode = $('#merge-box-code').text();
    if (!boxCode) {
        BootstrapDialog.alert("货箱编号为空");
        return;
    }
    $('#ware-box-code').val(boxCode);
    $('#goods-box-code').val(boxCode);
    const opt = $("#form-param").serializeJSON();
    const entry = $('#merge-box-list').bootstrapTable('getData');
    if (entry && entry.length > 0) {
        opt['list'] = entry;
    }
    console.log("临期报损后入库:" + JSON.stringify(opt));
    $('#merge-btn').hide();
    $('#merge-box-up').hide();

    //非空箱
    $.ajax({
        type: "POST",
        url: "/wcs/frmLossEntry",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(opt),
        dataType: "json",
        success: function (data) {
            if (data.code == 0) {
            } else {
                $('#merge-btn').show();
                $('#merge-box-up').show();
                BootstrapDialog.alert(data.msg);
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            if (XMLHttpRequest.responseJSON) {
                if (XMLHttpRequest.responseJSON.msg) {
                    BootstrapDialog.alert(XMLHttpRequest.responseJSON.msg);
                } else {
                    XMLHttpRequest.responseJSON.message
                }
            }
        }
    });
}

/**
 * 报损出库
 * @param id
 * @param {string} tableId
 */
function removeFrmLoss(id, tableId) {
    console.log("id:"+id+",tableId:"+tableId);
    const orderRow = $('#' + tableId).bootstrapTable('getRowByUniqueId', id);
    console.log("报损出库:" + JSON.stringify(orderRow));
    const opt = {};
    opt['data'] = orderRow;
    opt['bigProduct'] = 0;
    $.ajax({
        type: "POST",
        url: "/wcs/record/frm/loss",
        contentType: "application/json;charset=UTF-8",
        data: JSON.stringify(opt),
        dataType: "json",
        success: function (data) {
            if (data.code === 0) {
                $('#' + tableId).bootstrapTable('removeByUniqueId', id);
                $("#" + id + "_entry").attr("disabled", true);
                selectFrmLossBox(true, 0);
                $('#merge-table-list').bootstrapTable('removeByUniqueId', id);
            } else {
                BootstrapDialog.alert(data.msg);
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            if (XMLHttpRequest.responseJSON) {
                if (XMLHttpRequest.responseJSON.msg) {
                    BootstrapDialog.alert(XMLHttpRequest.responseJSON.msg);
                } else {
                    XMLHttpRequest.responseJSON.message
                }
            }
        }
    });
}

//空箱入库
function emptyEntry(id) {
    const orderRow = $('#merge-box-list').bootstrapTable('getRowByUniqueId', id);
    if (orderRow) {
        $('#' + orderRow.boxCode).hide();
        const ops = $("#form-param").serializeJSON();
        // ops['upOrDownPolicy']['spuId'] = orderRow.spuId;
        ops['upOrDownPolicy']['boxCode'] = orderRow.boxCode;
        ops['upOrDownPolicy']['boxType'] = 0;
        ops['upOrDownPolicy']['clientId'] = $('#client-id').val();
        ops['goodsBox']['boxCode'] = orderRow.boxCode;
        ops['outboundAndEntry'] = true;

        //空箱
        $.ajax({
            type: "POST",
            url: "/wcs/emptyEntry",
            contentType: "application/json;charset=UTF-8",
            data: JSON.stringify(ops),
            dataType: "json",
            success: function (data) {
                if (data.code == 0) {
                } else {
                    BootstrapDialog.show({
                        size: BootstrapDialog.SIZE_NORMAL,
                        message: data.msg,
                        closable: false,
                        buttons: [{
                            label: '继续入库',
                            cssClass: 'btn-primary',
                            action: function (dialog) {
                                emptyEntry(ops);
                                dialog.close();
                            }
                        }]
                    });
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                if (XMLHttpRequest.responseJSON) {
                    if (XMLHttpRequest.responseJSON.msg) {
                        BootstrapDialog.alert(XMLHttpRequest.responseJSON.msg);
                    } else {
                        XMLHttpRequest.responseJSON.message
                    }
                }
            }
        });
    } else {
        BootstrapDialog.alert("信息为空");
    }
}

//空箱入库离开缓存位后更改状态
function emptyEntryOfMerge(boxCode) {
    if (boxCode) {
        const ops = $("#form-param").serializeJSON();
        ops['upOrDownPolicy']['boxCode'] = boxCode;
        ops['upOrDownPolicy']['clientId'] = $('#client-id').val();
        ops['goodsBox']['boxCode'] = boxCode;
        //空箱
        $.ajax({
            type: "POST",
            url: "/wcs/emptyEntryOfMerge",
            contentType: "application/json;charset=UTF-8",
            data: JSON.stringify(ops),
            dataType: "json",
            success: function (data) {
                if (data.code == 0) {
                } else {
                    BootstrapDialog.show({
                        size: BootstrapDialog.SIZE_NORMAL,
                        message: data.msg,
                        closable: false,
                        buttons: [{
                            label: '继续入库',
                            cssClass: 'btn-primary',
                            action: function (dialog) {
                                emptyEntryOfMerge(boxCode);
                                dialog.close();
                            }
                        }]
                    });
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                if (XMLHttpRequest.responseJSON) {
                    if (XMLHttpRequest.responseJSON.msg) {
                        BootstrapDialog.alert(XMLHttpRequest.responseJSON.msg);
                    } else {
                        XMLHttpRequest.responseJSON.message
                    }
                }
            }
        });
    } else {
        BootstrapDialog.alert("信息为空");
    }
}